home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / undo / initMissingUpdatePools.c next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.8 KB  |  132 lines

  1. /*
  2.  *   $RCSfile: initMissingUpdatePools.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:56:03 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "log.h"
  39. #ifndef INIT_LRC_IS_LSN
  40.  
  41. #include "sysdefs.h"
  42. #include "ess.h"
  43. #include "checking.h"
  44. #include "trace.h"
  45. #include "error.h"
  46. #include "list.h"
  47. #include "tid.h"
  48. #include "io.h"
  49. #include "lock.h"
  50. #include "object.h"
  51. #include "msgdefs.h"
  52. #include "thread.h"
  53. #include "latch.h"
  54. #include "semaphore.h"
  55. #include "link.h"
  56. #include "lsn.h"
  57. #include "pool.h"
  58. #include "logrecs.h"
  59. #include "bf.h"
  60. #include "undo.h"
  61. #include "undo_extfuncs.h"
  62. #include "undo_globals.h"
  63. #include "bf_globals.h"
  64.  
  65.  
  66.  void
  67. initMissingUpdatePools()
  68.  
  69. {
  70.     
  71.     MISSINGUPDATEINFO    *missingUpdateInfo;
  72.     MISSINGUPDATE        *missingUpdate;
  73.     int                    tableCount = 4;            /* for testing     */
  74.     int                    tableEntryCount = 100;    /* for testing    */
  75.     int                    i,j;
  76.     
  77.     TRPRINT(TR_RECOVER, TR_LEVEL_1, (""));
  78.  
  79.     /*
  80.      *    Fill a pool of missing update info tables.
  81.      *    1. initialize the pool 
  82.      *    2. create the pool elements.
  83.      *    3. For each element, initialize it and add it to the pool
  84.      */
  85.     initializePool(&MissingUpdateInfoPool, NULL, tableCount);
  86.     missingUpdateInfo = (MISSINGUPDATEINFO*) 
  87.                         malloc(tableCount * sizeof(MISSINGUPDATEINFO));
  88.     if (missingUpdateInfo == NULL) {
  89.         SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
  90.     }
  91.     for (i = 0; i < tableCount; i++) {
  92.         initializeListElement(&(missingUpdateInfo[i].list), 
  93.                               (char*) &(missingUpdateInfo[i]) );
  94.         INIT_MISSINGUPDATEINFO_MAGIC(&(missingUpdateInfo[i]));
  95.         missingUpdateInfo[i].table = (LIST*) malloc(PageHashTableSize * sizeof(LIST));
  96.  
  97.         /*
  98.          *    Initialize each element of the table
  99.          */
  100.         for (j = 0; j < PageHashTableSize; j++) {
  101.             initializeList(&(missingUpdateInfo[i].table[j]));
  102.         }
  103.  
  104.         listEnq(&(MissingUpdateInfoPool.freeList), &(missingUpdateInfo[i].list));
  105.     }
  106.  
  107.     /*
  108.      *    Fill a pool of missing update info table entries.
  109.      *    1. initialize the pool 
  110.      *    2. create the pool elements.
  111.      *    3. For each element, initialize it and add it to the pool
  112.      */
  113.     initializePool(&MissingUpdatePool, NULL, tableEntryCount);
  114.     missingUpdate = (MISSINGUPDATE*) 
  115.                         malloc(tableEntryCount * sizeof(MISSINGUPDATE));
  116.     if (missingUpdate == NULL) {
  117.         SM_ERROR(TYPE_FATAL, esmMALLOCFAILED);
  118.     }
  119.     for (i = 0; i < tableEntryCount; i++) {
  120.         initializeListElement(&(missingUpdate[i].list), (char*) &(missingUpdate[i]) );
  121.         listEnq(&(MissingUpdatePool.freeList), &(missingUpdate[i].list));
  122.     }
  123.  
  124.     /*
  125.      *    Initialize the is of tables which are in use
  126.      */
  127.     initializeList(&(UsedMissingUpdateTables));
  128.  
  129.     return;
  130. }
  131. #endif INIT_LRC_IS_LSN
  132.